<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>攻略评论管理</title>
    <#include "../common/header.ftl"/>
    <#include "../common/page.ftl"/>
    <style type="text/css">
        .chosen-container {
            width: 250px !important;
        }
    </style>
    <script type="text/javascript">
       $(function () {
           // 评论回显
           $('.inputBtn').click(function() {
               $('#editForm')[0].reset();
               var data = $(this).data('json');
               console.log(data);
               if(data){
                   $('#editForm input[name="id"]').val(data.id);
                   $('#editForm select[name="strategy.id"]').val(data.StrategyId);
                   $('#editForm input[name="name"]').val(data.username);
                   $(".chosen").trigger("chosen:updated");
               }
               $('#editModal').modal('show');
           });
           $(".chosen").chosen({
               no_results_text: "没有找到结果！",//搜索无结果时显示的提示
               search_contains:true,   //关键字模糊搜索，设置为false，则只从开头开始匹配
               allow_single_deselect:true, //是否允许取消选择
               max_selected_options:6  //当select为多选时，最多选择个数
           });
           // 保存
           $('.btn_submit').click(function () {
               $('#editForm').ajaxSubmit(function (data) {
                   if(data.success){
                       window.location.reload();
                   }else {
                       $.messager.alert("温馨提示","保存失败" + data.msg);
                   }
               });
           });
       });
    </script>
</head>

<body>
<div class="container">
<#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
		<#assign currentMenu = "strategyComment" />
				<#include "../common/menu.ftl" />
        </div>
        <div class="col-sm-9">
            <div class="page-header">
                <h3>攻略评论管理</h3>
            </div>
            <div class="row">
                <!-- 提交分页的表单 -->
                <form id="searchForm" class="form-inline" method="post" action="/strategyComment/strategyList.do">
                    <input type="hidden" name="currentPage" id="currentPage" value="1"/>
                    <input type="hidden" name="type" id="type" value="1"/>
                    <div class="form-group">
                    </div>
                    <label>攻略搜索 </label>
                    <div class="form-group">
                        <select id="strategyId" name="strategyId"  class="form-control chosen">
                            <option value="-1">全部攻略</option>
                            <#list  strategies as s>
                                <option value="${s.id}">${s.title}</option>
                            </#list>
                        </select>
                        <script>
                            $('#strategyId').val(${(qo.strategyId)!});
                        </script>
                    </div>
                    <div class="form-group">
                        <button id="query" class="btn btn-success"><i class="icon-search"></i> 查询</button>
                        <#--<button type="button" class="btn btn-success inputBtn"><i class="icon-plus"></i> 添加</button>-->
                    </div>
                </form>
            </div>
            <div class="row">
                <table class="table">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>所属攻略</th>
                        <th>评论内容</th>
                        <th>评论时间</th>
                        <th>评论用户</th>
                    </tr>
                    </thead>
                    <tbody>
                    <#if qo.type != -1>
					<#list result.list as vo>
                    <tr>
                        <td>${vo_index+1}</td>
                        <td>${vo.targetname!}</td>
                        <td>${vo.content!}</td>
                        <td>${(vo.create_time?string("yyyy-MM-dd"))!}</td>
                        <td>${vo.username}</td>
                        <td>
                            <a href="javascript:;" class="btn btn-success inputBtn" data-json='${vo.jsonString!}'>修改</a>
                        </td>
                    </tr>
					</#list>
                    </#if>
                    </tbody>
                </table>

                <div style="text-align: center;">
                    <ul id="pagination" class="pagination"></ul>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="editModal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">修改</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/strategyComment/saveOrUpdate.do" method="post" id="editForm" >
                    <input type="hidden" value="" name="id">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">评论者名称：</label>
                        <div class="col-sm-6">
                            <input type="text" class="form-control" name="name">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-3 control-label">所属攻略 ：</label>
                        <div class="col-sm-6">
                        <select  name="strategy.id" class="form-control" disabled="disabled">
                            <option value="-1">全部攻略</option>
                            <#list  strategies as s>
                                <option value="${s.id}" >${s.title}</option>
                            </#list>
                        </select>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-3 control-label">状态：</label>
                        <div class="col-sm-6">
                            <select name="type" class="form-control">
                                <option value="0">请选择状态</option>
                                <option value="0">正常</option>
                                <option value="-1">禁用</option>
                            </select>
                        </div><br>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary btn_submit">保存</button>
                <button type="button" class="btn btn-danger" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>